﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
<div>
    <ul>
        @for (int i = 0; i < 10; i++)
        {
            <li>@i</li>
        }
    </ul>
    @*单语句块*@

    @{
        var greeting = "Hello world";
    }
    @*内联表达式*@
    <p>Razor 说 @greeting</p>
    @*多条语句块*@
    @{
        var message = "欢迎登录我的站点";
        var weekDay = DateTime.Now.DayOfWeek;
        var greetingMessage = message + "温州当地时间是" + weekDay;
    }
    <p>祝贺词是 @greetingMessage</p>

    @{
        var txt = "";
        txt = DateTime.Now.Hour <= 12 ? "上午好" : "下午好";
    }
    <p>问候语：@txt</p>
    <hr />
    @{
        var totalMessage = "";
        if (IsPost)
        {
            var num1 = Request["text1"];
            var num2 = Request["text2"];
            var total = num1.AsInt() + num2.AsInt();
            totalMessage = "Total = " + total;
        }
    }
    <form action="" method="post">
        <p>
            <label for="text1">First Number:</label><br>
            <input type="text" name="text1" />
        </p>
        <p>
            <label for="text2">Second Number:</label><br>
            <input type="text" name="text2" />
        </p>
        <p><input type="submit" value=" Add " /></p>
    </form>
    <p>@totalMessage</p>
</div>
    @*@{
        Response.Output.WriteLine("<script>alert('asd');</script>");
    }*@
</body>
</html>
